#include <bits/stdc++.h>
// 2025/03/31
// tag: 
// Author: Forever
using namespace std;
using int64 = int64_t;

int n, m, floyd[201][201], p[201][201];
bool imp[201];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    memset(floyd, 0x3f, sizeof(floyd));
    for (int i = 1; i <= n; i++)
        floyd[i][i] = 0;
    for (int i = 1; i <= m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        floyd[u][v] = w;
        floyd[v][u] = w;    
    }
    for (int k = 1; k <= n; k++)
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (floyd[i][k] + floyd[k][j] < floyd[i][j])
                    floyd[i][j] = floyd[i][k] + floyd[k][j], p[i][j] = k;
                else if (floyd[i][k] + floyd[k][j] == floyd[i][j] && p[i][j] != k && k != i && k != j)
                    p[i][j] = -1;
    int cnt = 0;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (p[i][j] != -1)
                imp[p[i][j]] = true;
    for (int i = 1; i <= n; i++)
        if (imp[i])
            cout << i << " ", cnt++;
    if (!cnt)
        cout << "No important cities." << endl;
    return 0;
}